#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc_energy_triplesdirect3.info <<'%EOF%'
   cc_energy_triplesdirect3
   ------------------------
   Molecule:         HF in C2
   Wave Function:    CCSD(T) / 6-31G**
   Test Purpose:     Integral direct calculation of CCSD(T) energy
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > cc_energy_triplesdirect3.mol <<'%EOF%'
BASIS
6-31G**
Hydrogen flourid
small test basis
    2    1  Y  X      1.00D-15
        9.0   1    
F     0.0000000000000000  0.0000000000000000 1.76320000000000000      
        1.0   1
H     0.0000000000000000  0.0000000000000000 0.00000000000000000      
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc_energy_triplesdirect3.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTIONS
.DIRECT
**INTEGRAL
.DIPLEN
**WAVE FUNCTIONS
.TITLE
  CCSD and CCSD(T) energy for HF molecule
.CC
*SCF INPUT 
.THRESH
 1.0d-12
*CC INPUT 
.CC(T)
.THRENR
 1.0d-10
.PRINT
 2
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc_energy_triplesdirect3.check
cat >>cc_energy_triplesdirect3.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

# SCF, MP2 and CCSD energies:
CRIT1=`$GREP "Final * HF energy:" $log | $GREP "\-100.008919(8|9)." | wc -l`
CRIT2=`$GREP "Total MP2   energy:                  \-100.193662(5|6)." $log | wc -l`
CRIT3=`$GREP "Total CCSD  energy:                  \-100.1977909." $log | wc -l`
CRIT4=`$GREP "The E4 doubles and triples:            ( \-|\-0)\.00236061" $log | wc -l`
CRIT5=`$GREP "The E5 singles and triples:             ( |0)\.00026249" $log | wc -l`
CRIT6=`$GREP "Total energy CCSD\(T\):                \-100\.1998890." $log | wc -l`
TEST[1]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[1]=11
ERROR[1]="ENERGIES NOT CORRECT"

PASSED=1
for i in 1
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%
#######################################################################
